<?php
require_once("../inc/bootstrap.php");

/* Tell this node to start downloading a new post
   Parameters: id=post ID, s=source server
*/

	if (!empty($_GET['id']) && !empty($_GET['s']))
	{
		$ID = intval($_GET['id']);
		if (!file_exists($uploadsDir.$ID))
			{
			ob_start();
			echo '1';
			$size = ob_get_length();
			header("Content-Length: $size");
			header('Connection: close');
			ob_end_flush();
			ob_flush();
			flush();
			getfile("http://$_GET['s'].$domain/api/download.php?id=$ID" ,$uploadsDir.$ID.'.tmp');
			rename($uploadsDir.$ID.'.tmp',$uploadsDir.$ID);
			exit;
			}
	}
	echo '0';
	exit;

?>